import { Controller, Get, Post, Body, Param, Query, Put, Req, Delete } from '@nestjs/common';
import { Menu_Service } from './menu.service';
import { Menu_Create_Dto, Menu_Update_Dto } from './assets/menu.dto';
import { Menu_Find_Dto } from './assets/menu.dto';
import { IRequest } from '@/common/typeScripts/index';
import { ApiExtraModels, ApiTags } from '@nestjs/swagger';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';
import { util_Index_ReturnContent } from '@/common/util/index';
import { Class_Index_ListAll } from '@/common/classes/index';

@Controller('/adm/menu')
@ApiTags('menu 菜单管理')
export class Menu_Controller {
  constructor(private readonly menu_Service: Menu_Service) {}

  @Post('/add')
  @util_ApiResponse_Base({
    dataType: 'dataType_add',
    //apiKey: '/adm/menu/add Post',
  })
  async menu_Create(@Body() body: Menu_Create_Dto) {
    return util_Index_ReturnContent(await this.menu_Service.menu_Create(body));
  }

  @Get('/myMenu')
  @util_ApiResponse_Base({
    dataType: 'dataType_ell',
    summary: '获取左侧菜单栏',
    //apiKey: '/adm/menu/myMenu Get',
  })
  async menu_Slider(@Req() req: IRequest) {
    return util_Index_ReturnContent(await this.menu_Service.menu_Slider(req));
  }

  @Get('/myMenuRoute')
  @util_ApiResponse_Base({
    dataType: 'dataType_ell',
    summary: '获取权限路由',
    //apiKey: '/adm/menu/myMenuRoute Get',
  })
  async menu_Route(@Req() req: IRequest) {
    return util_Index_ReturnContent(await this.menu_Service.menu_Route(req));
  }

  @Get('/list')
  @util_ApiResponse_Base({
    dataType: 'dataType_list',
    //apiKey: '/adm/menu/list Get',
  })
  async menu_FindByPage(@Query() query: Menu_Find_Dto) {
    return util_Index_ReturnContent(await this.menu_Service.menu_FindByPage(query));
  }

  @Get('/listSelect')
  @ApiExtraModels(Class_Index_ListAll)
  @util_ApiResponse_Base({
    dataType: 'dataType_listSelect',
    type: Class_Index_ListAll,
  })
  async menu_FindAllSelect() {
    return util_Index_ReturnContent(await this.menu_Service.menu_FindAllSelect());
  }

  @Put('/update')
  @util_ApiResponse_Base({
    dataType: 'dataType_update',
    //apiKey: '/adm/menu/update Put',
  })
  async menu_Update(@Body() body: Menu_Update_Dto) {
    return util_Index_ReturnContent(await this.menu_Service.menu_Update(body));
  }

  @Delete('/delete/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_delete',
    //apiKey: '/adm/menu/delete/:id Delete',
  })
  async menu_Remove(@Param('id') id: string) {
    return util_Index_ReturnContent(await this.menu_Service.menu_Remove(+id));
  }
}
